import java.util.*;
public class Main{

    //区域内砍树，数树
    //暴力算法，，，待优化
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int L = in.nextInt();//马路长度
        int M = in.nextInt();//区域数量
        int arr[] = new int[L + 1];
        for (int i = 0; i < L + 1; i++) {
            arr[i] = 1;
        }
        while (M-- > 0) {
            int begin = in.nextInt();
            int end = in.nextInt();
            cutTree(arr, begin, end);
        }
        int count = 0;
        for (int i = 0; i < L + 1; i++) {
            count += arr[i];
        }
        System.out.println(count);
    }
        public static void cutTree(int[] arr, int begin, int end){
            for(int i = begin; i <= end; i++){
                arr[i] = 0;
        }
    }

    //判断日期是否是回文
    //根据月、日生成的可能回文年份与给定年份区间进行比较
    //回文日期具有唯一性（回文年份一定与其月日相对应）
    public static void main2(String[] args) {
        int[] days = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        Scanner in = new Scanner(System.in);
        int begin = in.nextInt();
        int end = in.nextInt();
        int count = 0;
        for(int month = 1; month <= 12; month++){
            for(int day = 1; day <= days[month]; day++){
                int year =(day%10)*1000 + (day/10)*100 + (month%10)*10 + month/10;
                if(year >= begin/10000 && year <= end/10000)
                    count++;
            }
        }
        System.out.println(count);
    }

    //铺地毯
    //数组存储的是地毯铺设的范围坐标
    //逆序比较得到最上层的地毯编号
    //通过给定坐标落在已铺设地毯范围与否，判断该位置是否铺地毯
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] arr = new int[n][4];
        for(int i = 0; i < n; i++){
            arr[i][0] = in.nextInt();
            arr[i][1] = in.nextInt();
            arr[i][2] = in.nextInt();
            arr[i][3] = in.nextInt();
        }

        int x = in.nextInt();
        int y = in.nextInt();

        int temp = -1;
        //从后往前遍历，找到第一个符合条件的地毯
        for(int j = n-1; j >= 0; j--){
            if(x >= arr[j][0] && x <= arr[j][0] + arr[j][2] && y >= arr[j][1] && y <= arr[j][1] + arr[j][3]){
                temp = j+1;
                break;
            }
        }
        System.out.print(temp);
    }
}